<?php

namespace App\Http\Controllers\Api\Home;

use App\Http\Controllers\Api\Controller;
use App\Models\Jinpai;
use App\Transformers\JinpaiTramsformer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class JinpaiController extends Controller
{
    //
    public function index(Request $request,Jinpai $jinpai){
        $params = $request->all();
        $query = $jinpai->query();
        if (!empty($params['is_hot'])){
            $query->where('is_hot','=','1');
        }
        if (!empty($params['cate_id'])){
            $query->where('cate_id','=',$params['cate_id']);
        }
        $result = $query->paginate(20);
        return $this->response->paginator($result,new JinpaiTramsformer());
    }
}
